/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * PantallaPrincipal.java
 *
 * Created on Mar 22, 2011, 8:50:47 PM
 */

package forms;

import beans.Socio;
import java.awt.Cursor;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

/**
 *
 * @author nMoncho
 */
public class PantallaPrincipal extends javax.swing.JFrame {

    /** Creates new form PantallaPrincipal */
    public PantallaPrincipal() {
        initComponents();
        this.setLocation(200, 200);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        toolBar = new javax.swing.JToolBar();
        botonAgregarSocio = new javax.swing.JButton();
        botonAgregarVisita = new javax.swing.JButton();
        botonRankSocios = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        botonSalir = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        menuArchivo = new javax.swing.JMenu();
        menuItemSalir = new javax.swing.JMenuItem();
        menuSocios = new javax.swing.JMenu();
        menuItemAgregarSocio = new javax.swing.JMenuItem();
        menuItemVisita = new javax.swing.JMenuItem();
        menuItemVerSocios = new javax.swing.JMenuItem();
        menuReportes = new javax.swing.JMenu();
        menuItemRankingSocios = new javax.swing.JMenuItem();
        menuComplementos = new javax.swing.JMenu();
        menuItemBarrios = new javax.swing.JMenuItem();
        menuItemBebidas = new javax.swing.JMenuItem();
        menuItemMedios = new javax.swing.JMenuItem();
        menuItemMusicas = new javax.swing.JMenuItem();
        menuItemProfesiones = new javax.swing.JMenuItem();
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        jMenu1 = new javax.swing.JMenu();
        menuItemRankInvitados = new javax.swing.JMenuItem();
        menuItemRankDia = new javax.swing.JMenuItem();
        jSeparator2 = new javax.swing.JPopupMenu.Separator();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Pantalla Principal");
        setIconImage(new ImageIcon(getClass().getResource("/resources/arrow-branch-bgr-16-ns.png")).getImage());

        toolBar.setRollover(true);

        botonAgregarSocio.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/person-plus-24.png"))); // NOI18N
        botonAgregarSocio.setToolTipText("Agregar un nuevo socio");
        botonAgregarSocio.setBorderPainted(false);
        botonAgregarSocio.setFocusable(false);
        botonAgregarSocio.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        botonAgregarSocio.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        botonAgregarSocio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAgregarSocioActionPerformed(evt);
            }
        });
        toolBar.add(botonAgregarSocio);

        botonAgregarVisita.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/page-forum-24.png"))); // NOI18N
        botonAgregarVisita.setToolTipText("Agregar Visitas");
        botonAgregarVisita.setBorderPainted(false);
        botonAgregarVisita.setFocusable(false);
        botonAgregarVisita.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        botonAgregarVisita.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        botonAgregarVisita.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonAgregarVisitaActionPerformed(evt);
            }
        });
        toolBar.add(botonAgregarVisita);

        botonRankSocios.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/clipboard-report-bar-24.png"))); // NOI18N
        botonRankSocios.setToolTipText("Ver Ranking");
        botonRankSocios.setBorderPainted(false);
        botonRankSocios.setFocusable(false);
        botonRankSocios.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        botonRankSocios.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        botonRankSocios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonRankSociosActionPerformed(evt);
            }
        });
        toolBar.add(botonRankSocios);
        toolBar.add(jSeparator1);

        botonSalir.setIcon(new javax.swing.ImageIcon(getClass().getResource("/resources/badge-circle-power-24.png"))); // NOI18N
        botonSalir.setToolTipText("Salir");
        botonSalir.setBorderPainted(false);
        botonSalir.setFocusable(false);
        botonSalir.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        botonSalir.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        botonSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                botonSalirActionPerformed(evt);
            }
        });
        toolBar.add(botonSalir);

        menuArchivo.setText("Archivo");

        menuItemSalir.setText("Salir");
        menuItemSalir.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemSalirActionPerformed(evt);
            }
        });
        menuArchivo.add(menuItemSalir);

        jMenuBar1.add(menuArchivo);

        menuSocios.setText("Socios");

        menuItemAgregarSocio.setText("Agregar Socio");
        menuItemAgregarSocio.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemAgregarSocioActionPerformed(evt);
            }
        });
        menuSocios.add(menuItemAgregarSocio);

        menuItemVisita.setText("Agregar Visita");
        menuItemVisita.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemVisitaActionPerformed(evt);
            }
        });
        menuSocios.add(menuItemVisita);

        menuItemVerSocios.setText("Ver Socios");
        menuItemVerSocios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemVerSociosActionPerformed(evt);
            }
        });
        menuSocios.add(menuItemVerSocios);

        jMenuBar1.add(menuSocios);

        menuReportes.setText("Reportes");

        menuItemRankingSocios.setText("Ranking de Socios");
        menuItemRankingSocios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemRankingSociosActionPerformed(evt);
            }
        });
        menuReportes.add(menuItemRankingSocios);

        jMenuBar1.add(menuReportes);

        menuComplementos.setText("Complementos");

        menuItemBarrios.setText("Gestionar Barrios");
        menuItemBarrios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemBarriosActionPerformed(evt);
            }
        });
        menuComplementos.add(menuItemBarrios);

        menuItemBebidas.setText("Gestionar Bebidas");
        menuItemBebidas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemBebidasActionPerformed(evt);
            }
        });
        menuComplementos.add(menuItemBebidas);

        menuItemMedios.setText("Gestionar Medios");
        menuItemMedios.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemMediosActionPerformed(evt);
            }
        });
        menuComplementos.add(menuItemMedios);

        menuItemMusicas.setText("Gestionar Musicas");
        menuItemMusicas.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemMusicasActionPerformed(evt);
            }
        });
        menuComplementos.add(menuItemMusicas);

        menuItemProfesiones.setText("Gestionar Profesiones");
        menuItemProfesiones.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemProfesionesActionPerformed(evt);
            }
        });
        menuComplementos.add(menuItemProfesiones);
        menuComplementos.add(jSeparator3);

        jMenu1.setText("Gestionar Puntajes");

        menuItemRankInvitados.setText("Puntos de Invitados");
        menuItemRankInvitados.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemRankInvitadosActionPerformed(evt);
            }
        });
        jMenu1.add(menuItemRankInvitados);

        menuItemRankDia.setText("Puntos de Dias");
        menuItemRankDia.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                menuItemRankDiaActionPerformed(evt);
            }
        });
        jMenu1.add(menuItemRankDia);

        menuComplementos.add(jMenu1);
        menuComplementos.add(jSeparator2);

        jMenuBar1.add(menuComplementos);

        setJMenuBar(jMenuBar1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(toolBar, javax.swing.GroupLayout.DEFAULT_SIZE, 400, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(toolBar, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(246, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void botonAgregarSocioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAgregarSocioActionPerformed
        abrirVentana(AGREGAR_SOCIO);
    }//GEN-LAST:event_botonAgregarSocioActionPerformed

    private void botonAgregarVisitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonAgregarVisitaActionPerformed
        abrirVentana(AGREGAR_VISITA);
    }//GEN-LAST:event_botonAgregarVisitaActionPerformed

    private void botonSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonSalirActionPerformed
        int respuesta = JOptionPane.showConfirmDialog(this, "¿Esta seguro que desea salir?", "Confirmacion", JOptionPane.INFORMATION_MESSAGE+JOptionPane.YES_NO_OPTION);
        if(respuesta == JOptionPane.YES_OPTION)
            System.exit(0);
    }//GEN-LAST:event_botonSalirActionPerformed

    private void menuItemSalirActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemSalirActionPerformed
        int respuesta = JOptionPane.showConfirmDialog(this, "¿Esta seguro que desea salir?", "Confirmacion", JOptionPane.INFORMATION_MESSAGE+JOptionPane.YES_NO_OPTION);
        if(respuesta == JOptionPane.YES_OPTION)
            System.exit(0);
    }//GEN-LAST:event_menuItemSalirActionPerformed

    private void menuItemAgregarSocioActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemAgregarSocioActionPerformed
        abrirVentana(AGREGAR_SOCIO);
    }//GEN-LAST:event_menuItemAgregarSocioActionPerformed

    private void menuItemVisitaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemVisitaActionPerformed
        abrirVentana(AGREGAR_VISITA);
    }//GEN-LAST:event_menuItemVisitaActionPerformed

    private void menuItemBarriosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemBarriosActionPerformed
        abrirVentana(GESTIONAR_BARRIOS);
    }//GEN-LAST:event_menuItemBarriosActionPerformed

    private void menuItemBebidasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemBebidasActionPerformed
        abrirVentana(GESTIONAR_BEBIDAS);
    }//GEN-LAST:event_menuItemBebidasActionPerformed

    private void menuItemMediosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemMediosActionPerformed
        abrirVentana(GESTIONAR_MEDIOS);
    }//GEN-LAST:event_menuItemMediosActionPerformed

    private void menuItemMusicasActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemMusicasActionPerformed
        abrirVentana(GESTIONAR_MUSICAS);
    }//GEN-LAST:event_menuItemMusicasActionPerformed

    private void menuItemProfesionesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemProfesionesActionPerformed
        abrirVentana(GESTIONAR_PROFESIONES);
    }//GEN-LAST:event_menuItemProfesionesActionPerformed

    private void menuItemRankInvitadosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemRankInvitadosActionPerformed
        abrirVentana(GESTIONAR_RANK_INVITADOS);
    }//GEN-LAST:event_menuItemRankInvitadosActionPerformed

    private void menuItemRankDiaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemRankDiaActionPerformed
        abrirVentana(GESTIONAR_RANK_DIAS);
    }//GEN-LAST:event_menuItemRankDiaActionPerformed

    private void menuItemRankingSociosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemRankingSociosActionPerformed
        abrirVentana(VER_RANKING);
    }//GEN-LAST:event_menuItemRankingSociosActionPerformed

    private void botonRankSociosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_botonRankSociosActionPerformed
        abrirVentana(VER_RANKING);
    }//GEN-LAST:event_botonRankSociosActionPerformed

    private void menuItemVerSociosActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_menuItemVerSociosActionPerformed
        abrirVentana(VER_SOCIOS);
    }//GEN-LAST:event_menuItemVerSociosActionPerformed

    public void abrirVentana(int ventana) {
        Cursor mouserCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
        setCursor(mouserCursor);

        if(ventanaActual != null)
            ventanaActual.dispose();

        switch(ventana){
            case VER_SOCIOS: ventanaActual = new VerSociosV2(this);break;
            case AGREGAR_SOCIO: ventanaActual = new CargaSocio();break;
            case AGREGAR_VISITA: ventanaActual = new CargaVisita();break;
            case VER_RANKING: ventanaActual = new RankSocios();break;
            case GESTIONAR_BARRIOS: ventanaActual = new CargarBarrios();break;
            case GESTIONAR_RANK_DIAS: ventanaActual = new CargaRankDias();break;
            case GESTIONAR_BEBIDAS: ventanaActual = new CargarBebidas();break;
            case GESTIONAR_MUSICAS: ventanaActual = new CargarMusica();break;
            case GESTIONAR_MEDIOS: ventanaActual = new CargarMedios();break;
            case GESTIONAR_PROFESIONES: ventanaActual = new CargaProfesiones();break;
            case GESTIONAR_RANK_INVITADOS: ventanaActual = new CargarRankInvitados(); break;
        }
        if(ventanaActual != null)
            ventanaActual.setVisible(true);

        mouserCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
        setCursor(mouserCursor);
    }

    public void abrirVentanaEdicio(Socio socio){
        Cursor mouserCursor = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR);
        setCursor(mouserCursor);

        if(ventanaActual != null)
            ventanaActual.dispose();

        ventanaActual = new CargaSocio(socio);

        if(ventanaActual != null)
            ventanaActual.setVisible(true);

        mouserCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
        setCursor(mouserCursor);
    }

    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                new PantallaPrincipal().setVisible(true);
            }
        });
    }

    private JFrame ventanaActual;

    public static final int AGREGAR_SOCIO = 1;
    private static final int AGREGAR_VISITA = 2;
    private static final int VER_RANKING = 3;
    private static final int GESTIONAR_BARRIOS = 4;
    private static final int GESTIONAR_RANK_DIAS = 5;
    private static final int GESTIONAR_BEBIDAS = 6;
    private static final int GESTIONAR_MUSICAS = 7;
    private static final int GESTIONAR_MEDIOS = 8;
    private static final int GESTIONAR_PROFESIONES = 9;
    private static final int GESTIONAR_RANK_INVITADOS = 10;
    private static final int VER_SOCIOS = 11;


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton botonAgregarSocio;
    private javax.swing.JButton botonAgregarVisita;
    private javax.swing.JButton botonRankSocios;
    private javax.swing.JButton botonSalir;
    private javax.swing.JMenu jMenu1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JMenu menuArchivo;
    private javax.swing.JMenu menuComplementos;
    private javax.swing.JMenuItem menuItemAgregarSocio;
    private javax.swing.JMenuItem menuItemBarrios;
    private javax.swing.JMenuItem menuItemBebidas;
    private javax.swing.JMenuItem menuItemMedios;
    private javax.swing.JMenuItem menuItemMusicas;
    private javax.swing.JMenuItem menuItemProfesiones;
    private javax.swing.JMenuItem menuItemRankDia;
    private javax.swing.JMenuItem menuItemRankInvitados;
    private javax.swing.JMenuItem menuItemRankingSocios;
    private javax.swing.JMenuItem menuItemSalir;
    private javax.swing.JMenuItem menuItemVerSocios;
    private javax.swing.JMenuItem menuItemVisita;
    private javax.swing.JMenu menuReportes;
    private javax.swing.JMenu menuSocios;
    private javax.swing.JToolBar toolBar;
    // End of variables declaration//GEN-END:variables

}
